<!-- 后评价 -->
<template>
    <el-descriptions :column="2" size="large" class="td-item">
      <el-descriptions-item label-class-name="right-align" label='项目名称'>
        <span class="text--info subtext">{{projectInfo?.projectName}}</span>
      </el-descriptions-item>

      <el-descriptions-item label-class-name="right-align" label='项目编号'>
        <span class="text--info subtext">{{projectInfo?.projectCode}}</span>
      </el-descriptions-item>

      <el-descriptions-item label-class-name="right-align" label='评审项目阶段'>
        <span v-if="projectInfo?.billName?.includes('关闭项目-审批流程')" class="text--info subtext">关闭</span>
        <span v-else class="text--info subtext">后评价</span>
      </el-descriptions-item>

      <el-descriptions-item label-class-name="right-align" label='项目审批类型'>
        <span class="text--info subtext">{{projectInfo?.approveTypeMaxName}} - {{projectInfo?.approveTypeMinName}}</span>
      </el-descriptions-item>

      <el-descriptions-item label-class-name="right-align" label='项目开始时间'>
        <span class="text--info subtext">{{projectInfo?.ext1?.slice(0,10)}}</span>
      </el-descriptions-item>

      <el-descriptions-item label-class-name="right-align" label='项目预计验收时间'>
        <span class="text--info subtext">{{projectInfo?.ext2?.slice(0,10)}}</span>
      </el-descriptions-item>

      <el-descriptions-item label-class-name="right-align" label='项目预类型'>
        <span class="text--info subtext">{{projectInfo.projectTypeName}}</span>
      </el-descriptions-item>

      <el-descriptions-item label-class-name="right-align" label='所属公司主体'>
        <span class="text--info subtext">{{projectInfo.principalCompanyName}}</span>
      </el-descriptions-item>

      <el-descriptions-item label-class-name="right-align" label='项目负责人'>
        <span class="text--info subtext">{{projectInfo.projectLeaderName}}</span>
      </el-descriptions-item>

      <el-descriptions-item label-class-name="right-align" label='项目联系人'>
        <span class="text--info subtext">{{projectInfo?.ext4}}</span>
      </el-descriptions-item>

      <el-descriptions-item label-class-name="right-align" label='项目负责人电话'>
        <span class="text--info subtext">{{projectInfo?.projectLeaderPhone}}</span>
      </el-descriptions-item>

      <el-descriptions-item label-class-name="right-align" label='项目联系人电话'>
        <span class="text--info subtext">{{projectInfo?.projectContactPhone}}</span>
      </el-descriptions-item>

      <el-descriptions-item label-class-name="right-align" label='项目负责人邮箱'>
        <span class="text--info subtext">{{projectInfo.projectLeaderEmail}}</span>
      </el-descriptions-item>

      <el-descriptions-item label-class-name="right-align" label='项目联系人邮箱'>
        <span class="text--info subtext">{{projectInfo?.projectContactEmail}}</span>
      </el-descriptions-item>

      <el-descriptions-item label-class-name="right-align" label='是否含可行性研究'>
        <span class="text--info subtext" v-text='projectInfo?.isFsbStudy == 1 ? "是" :"否"' ></span>
      </el-descriptions-item>

      <el-descriptions-item label-class-name="right-align" label='项目立项书'>
        <div v-if="projectInfo?.projectProposalArr?.length" class="file-wrap">
          <p
            class="text--info download-link subtext"
            v-for="(obj, index) in projectInfo?.projectProposalArr"
            :key="index"
            @click.prevent="handlePreview(obj)"
          >
            <el-link :underline="false" icon="el-icon-folder">{{ obj?.fileName }}</el-link>
          </p>
        </div>

        <div class="text--info subtext file-wrap" v-else> - </div>
      </el-descriptions-item>

      <el-descriptions-item label-class-name="right-align" label='项目申报材料'>
        <div v-if="projectInfo?.kyFilesArr?.length" class="file-wrap">
          <p
            class="text--info download-link subtext"
            v-for="(obj, index) in projectInfo?.kyFilesArr"
            :key="index"
            @click.prevent="handlePreview(obj)"
          >
            <el-link :underline="false" icon="el-icon-folder">{{ obj?.fileName }}</el-link>
          </p>
        </div>
        <div class="text--info subtext file-wrap" v-else> - </div>
      </el-descriptions-item>

      <el-descriptions-item label-class-name="right-align" label='后评价附件'>
        <div v-if="projectInfo?.evaluationAttachmentList?.length" class="file-wrap">
          <p
            class="text--info download-link subtext"
            v-for="(obj, index) in projectInfo?.evaluationAttachmentList"
            :key="index"
            @click.prevent="handlePreview(obj)"
          >
            <el-link :underline="false" icon="el-icon-folder">{{ obj?.fileName }}</el-link>
          </p>
        </div>
        <div class="text--info subtext file-wrap" v-else> - </div>
      </el-descriptions-item>

      <el-descriptions-item label-class-name="right-align" label='项目验收报告'>
        <div v-if="checkDetail?.accReportAttachmentArr?.length" class="file-wrap">
          <p
            class="text--info download-link subtext"
            v-for="(obj, index) in checkDetail?.accReportAttachmentArr"
            :key="index"
            @click.prevent="handlePreview(obj)"
          >
            <el-link :underline="false" icon="el-icon-folder">{{ obj?.fileName }}</el-link>
          </p>
        </div>
        <div class="text--info subtext file-wrap" v-else> - </div>
      </el-descriptions-item>

      <el-descriptions-item label-class-name="right-align" label='项目经费决算报告'>
        <div v-if="checkDetail?.finaReportAttachmentArr?.length" class="file-wrap">
          <p
            class="text--info download-link subtext"
            v-for="(obj, index) in checkDetail?.finaReportAttachmentArr"
            :key="index"
            @click.prevent="handlePreview(obj)"
          >
            <el-link :underline="false" icon="el-icon-folder">{{ obj?.fileName }}</el-link>
          </p>
        </div>
        <div class="text--info subtext file-wrap" v-else> - </div>
      </el-descriptions-item>

    </el-descriptions>
</template>

<script lang="ts" setup>
  import axios from "axios";
import { onMounted, ref, watch } from "vue";
import { useRoute } from "vue-router";
import { storageLocal } from "/@/utils/storage";
const props = defineProps({
  projectInfo: {
    type: Object,
    default:()=>{}
  },
});
const route = useRoute();
const projectInfo = ref({});
const checkDetail = ref({})
const baseUrl = ref(import.meta.env.VITE_BASE_URL);
watch(
  () => props.projectInfo,
  newvalue => {
    projectInfo.value = newvalue;
    if(projectInfo.value.evaluationAttachment){
      projectInfo.value.evaluationAttachmentList = JSON.parse(projectInfo.value.evaluationAttachment)
    }
  },
  { immediate: true }
);

//获取项目验收详情
const initProjectInfo = async () => {
  const queryId = route.query?.projectManageId ?? "";
  const getExpertUrl = `${baseUrl.value}/rdms-admin/project/stage/acceptance/detail/${queryId}`;
  const headers = { headers: {Authorization: storageLocal.getItem("rdms-info")?.accessToken}}
  try {
    const res = await axios.post(getExpertUrl,'',headers);
    if (res.status === 200) {
      checkDetail.value = res.data?.data;
    }
  } catch (err) {
    console.log(err);
  }
};


onMounted(() => {
  projectInfo.value = props.projectInfo;
  initProjectInfo()
});

const handlePreview = (item: any) => {
  if (item.response) {
    window.open(
      `${location.origin}${location.pathname}#/online?uuidFile=${item?.response.data.uuidFile}&fileName=${item?.response.data.fileName}`
    );
  } else {
    window.open(
      `${location.origin}${location.pathname}#/online?uuidFile=${item.uuidFile}&fileName=${item.fileName}`
    );
  }
};
</script>

<style lang="scss" scoped>
  .file-wrap{
    display: inline-block;
    vertical-align: top
  }
</style>
